#include <iostream>



int *func() {
    // 利用new关键字 可以将数据开辟到堆区
    int *pInt = new int(10);
    return pInt;
}

// 堆区开辟数组
int *test() {
    int *arr = new int [10];
    for (int i = 0; i < 10; ++i) {
        arr[i] = i + 100;
    }

    return arr;
}

int main() {

    int *pInt = func();

    std::cout << *pInt << std::endl;

    delete pInt; // 释放堆中内存

    std::cout << *pInt << std::endl;

    int *pInt1 = test();
    delete[] pInt1; // 释放数组
}

